package com.kaibes.module.shelter;

import java.util.List;

import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.kaibes.web.api.ApiLink;
import com.kaibes.web.api.ResponseApi;

@RestController
@RequestMapping("/shelters")
public class ShelterApi extends ResponseApi<Shelter, ShelterService> {

    @PostMapping
    @ApiLink("创建屏蔽规则")
    public ResponseEntity<List<Number>> post(@RequestBody @Validated Shelter shelter) {
        return super.post(shelter, "创建屏蔽成功", "创建屏蔽失败");
    }

    @DeleteMapping("/{id:\\d+}")
    @ApiLink("删除屏蔽规则")
    public ResponseEntity<Object> delete(@PathVariable Integer id) {
        return super.deleteById(id, "删除屏蔽成功", "删除屏蔽失败");
    }

    @DeleteMapping
    @ApiLink("删除屏蔽规则")
    public ResponseEntity<Object> delete(@RequestBody List<Integer> ids) {
        return super.deleteByIds(ids, "删除屏蔽成功", "删除屏蔽失败");
    }

    @PutMapping("/{id:\\d+}")
    @ApiLink("修改屏蔽规则")
    public ResponseEntity<Object> putById(@PathVariable Integer id, @RequestBody ShelterUpdate data) {
        return super.putById(data, id, "修改屏蔽成功", "修改屏蔽失败");
    }

}
